<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "news".
 *
 * @property string $id
 * @property integer $pid
 * @property string $title
 * @property string $message
 * @property string $logo
 * @property integer $createtime
 * @property integer $look
 * @property string $source
 */
class News extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'news';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['pid', 'title', 'message', 'logo', 'createtime', 'source'], 'required'],
            [['pid', 'createtime'], 'integer'],
            [['message'], 'string'],
            [['title'], 'string', 'max' => 30],
            [['logo'], 'string', 'max' => 50],
            [['source'], 'string', 'max' => 10],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'pid' => '上级栏目',
            'title' => '标题',
            'message' => '内容',
            'logo' => '主图',
            'createtime' => '发布时间',
            'look' => '浏览量',
            'source' => '来源',
        ];
    }
    public function getNewColumn(){
        return $this->hasOne(NewColumn::className(), ['id'=>'pid']);
    }
}
